package com.admin.business.personalCenter.venusPortalUserOrder;

import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 助业网订单记录表
 * @create: 2023-11-23 14:59:29
 **/
@Service("venusPortalUserOrderService")
@Slf4j
public class VenusPortalUserOrderService{

    @Resource
    VenusPortalUserOrderDao venusPortalUserOrderDao;

    /**
     * 添加助业网订单记录表,获取id数据
     *
     * @param cdoRequest - id:主键订单号
     *                   - userId:用户ID
     *                   - orderTransaction:交易目标ID
     *                   - orderMoney:金额
     *                   - orderCurrency:流动助业币
     *                   - orderDescription:订单叙述
     *                   - orderStatus:订单状态：0、充值，1，提现，2、助业币充值，3、助业币交易，4、会员充值 5、代理充值 7、短信充值 8、广告管理 12、成立业委会充值 13.物业费未达标开通费
     *                   - orderBusiness:订单业务：0、系统，1、打赏，2、提问，3、购买服务
     *                   - orderVariable:支付状态：0、其他，1、待支付，2、已支付，
     *                   - orderFlow:助业币流动：0、入账 1、出账
     *                   - beginTime:创建时间
     *                   - updateTime:更新时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return addVenusPortalUserOrder(CDO cdoRequest) {
        venusPortalUserOrderDao.addVenusPortalUserOrder(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("id")) {
            cdoResult.set("id", cdoRequest.get("id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据id，更新助业网订单记录表数据
     *
     * @param cdoRequest - id:主键订单号
     *                   - userId:用户ID
     *                   - orderTransaction:交易目标ID
     *                   - orderMoney:金额
     *                   - orderCurrency:流动助业币
     *                   - orderDescription:订单叙述
     *                   - orderStatus:订单状态：0、充值，1，提现，2、助业币充值，3、助业币交易，4、会员充值 5、代理充值 7、短信充值 8、广告管理 12、成立业委会充值 13.物业费未达标开通费
     *                   - orderBusiness:订单业务：0、系统，1、打赏，2、提问，3、购买服务
     *                   - orderVariable:支付状态：0、其他，1、待支付，2、已支付，
     *                   - orderFlow:助业币流动：0、入账 1、出账
     *                   - beginTime:创建时间
     *                   - updateTime:更新时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return updateVenusPortalUserOrderById(CDO cdoRequest) {
        venusPortalUserOrderDao.updateVenusPortalUserOrderById(cdoRequest);
        return Return.SUCCESS;
    }

    /**
     * 根据id，删除助业网订单记录表数据
     *
     * @param cdoRequest - id:主键订单号
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return deleteVenusPortalUserOrderById(CDO cdoRequest){
        int count = venusPortalUserOrderDao.deleteVenusPortalUserOrderById(cdoRequest.getString("id"));
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除助业网订单记录表数据
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return deleteVenusPortalUserOrder(CDO cdoRequest) {
        int count = venusPortalUserOrderDao.deleteVenusPortalUserOrder(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取助业网订单记录表数据
     *
     * @param cdoRequest - id:主键订单号
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusPortalUserOrderById(CDO cdoRequest) {
        CDO cdoMapperResult = venusPortalUserOrderDao.getVenusPortalUserOrderById(cdoRequest.getString("id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取助业网订单记录表数据列表
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusPortalUserOrderListPage(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusPortalUserOrderDao.getVenusPortalUserOrderListPage(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusPortalUserOrderDao.getVenusPortalUserOrderCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
    /**
     * 根据混合条件，获取助业网订单记录表数据列表
     *
     * @param cdoRequest - id:主键订单号
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusPortalUserOrderListPageByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusPortalUserOrderDao.getVenusPortalUserOrderListPageByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusPortalUserOrderDao.getVenusPortalUserOrderCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
}
